/**
 * 
 */
package com.google.code.netz.wfe.model;

import java.util.UUID;

import com.google.code.netz.wfe.api.IManaged;

/**
 * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
 * @since 1.0
 * @version $Id: AbstractPetriNetEntity.java 17 2009-02-09 13:08:49Z rahul.thakur.xdev $
 */
public abstract class AbstractPetriNetEntity<T> implements IPetriNetEntity<T>, IManaged {

	/**
	 * Univerally Unique Identifier that represents a 128-bit value.
	 * <p>
	 * This is used by the workflow engine internally.
	 * 
	 * @see <a
	 *      href='http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html'>J
	 *      D K 5.0 docs</a>
	 */
	private UUID uuid;

	/**
	 * Human readable label.
	 */
	private String label;

	private T data;

	private State currentState = State.STATE_DEFAULT;

	/**
     * 
     */
	public AbstractPetriNetEntity(String label) {
		super();
		uuid = UUID.randomUUID();
		this.label = label;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.google.code.netz.wfe.model.IPetriNetEntity#getId()
	 */
	@Override
	public UUID getId() {
		// TODO Auto-generated method stub
		return this.uuid;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.google.code.netz.wfe.model.IPetriNetEntity#getLabel()
	 */
	public String getLabel() {
		return this.label;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.google.code.netz.wfe.model.IPetriNetEntity#getData()
	 */
	@Override
	public T getData() {
		return this.data;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.google.code.netz.wfe.model.IPetriNetEntity#setData(java.lang.Object)
	 */
	@Override
	public void setData(T data) {
		this.data = data;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.google.code.netz.wfe.api.IManaged#getCurrentState()
	 */
	@Override
	public State getCurrentState() {
		return this.currentState;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see com.google.code.netz.wfe.api.IManaged#setCurrentState(com.google.code.netz.wfe.model.State)
	 */
	@Override
	public void setCurrentState(State state) {
		this.currentState = state;
	}

}
